import xlrd

class excel_action():
    # 获取单个值
    def read_excel_values(self,address,sheet,row,col):  #获取单个值
        row=row-1
        col=col-1
        self.excel=xlrd.open_workbook(address)
        self.table=self.excel.sheets()[sheet]
        excel_values=self.table.row_values(row)[col]  #row 行号，col 列
        return excel_values

    # 读取一行的值
    def read_excel_row(self,address,sheet,row):
        self.excel = xlrd.open_workbook(address)
        self.table = self.excel.sheets()[sheet]
        table_values_row = self.table.row_values(row)
        return table_values_row

    # 读取一列的值
    def read_excel_col(self,address,sheet,col):
        col = col-1
        self.excel = xlrd.open_workbook(address)
        self.table = self.excel.sheets()[sheet]
        table_values_col = self.table.col_values(col)
        return table_values_col
